<%@page import="java.util.ArrayList"%>
<%@page import="user.User"   contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">


<html>
    <head>
        <link type="text/css" rel="stylesheet" href="sidebar.css" media="screen" />

        <title>Profile Page</title>
<%User userInfo=null;
        userInfo = (User) session.getAttribute("userInfo");
        User friend=new User();
        ArrayList friends=null;
        String username=null,name=null,surname=null,date=null,welcomeText=null;
        String []interests=null;

        //re-visit own profile
            out.print("Welcome "+session.getAttribute("username")+"");
               userInfo = (User) session.getAttribute("userInfo");
                
                //out.println("id " + session.getAttribute("id") + " </br>");
                name=session.getAttribute("name").toString();
                surname=session.getAttribute("surname").toString();
                interests=session.getAttribute("interests").toString().split(",");
               username=session.getAttribute("username").toString();
        //        welcomeText=session.getAttribute("welcomeText").toString();
                date=session.getAttribute("dateOfBirth").toString();

                userInfo.loadFriendList();
                friends=(ArrayList)session.getAttribute("friends");
               friends=userInfo.getFriendUsernames();
        %>
    </head>
    <body>
        <div id ="footbar">
            <div id="RightBar">
            	<br>
                <a href="endSession.jsp"><b>
                <input type="image" src="imadge/on-off.jpg" name="image" background-color="#C0C0C0" width="35" height="35" >
                    </b>
                </a>
            </div>
        </div>
 <div id="rightbar" class="sidebox">
     
     <table id="right">
           <tr> <td>
        <hr>
             <ul>

   <%
                  if(friends!=null&&friends.size()>1)
                      {out.println("Your Friends are "+friends.size()+"</br> ");



                                for(int i=0;i<friends.size();i++){
%>

<li><b>

                    <%out.println("<a href=profile.jsp?username=" + friends.get(i) + ">" + friends.get(i) + "</a></br>");
               }}
               %>

    </b></li>

		<%

               String[] suggestions = userInfo.SuggestFriends();
               if(suggestions!=null)
               if(suggestions.length>=1)
               %><li><% out.print("You should be friends with</br>");
               %></li>><%
                for (int i = 0; i < suggestions.length; i++) {
                    %>

<li><b>
               <%out.print("<a href=profile.jsp?username=" + suggestions[i] + ">" + suggestions[i] + "</a></br>");
                }


            %>
            <a href="manageFriends.jsp">Manage Your Friends</a>
         </b></li>
             
             </ul>
            <hr>
                comon-popular </br>
                interests list
            <hr>
                </td>
           </tr>
        </table>





</div>
     <div id ="headbar">
            <h1>Abandonware <br/> Place</h1>
            <div id ="searchbar">
            <form action="search.jsp">
   <input type="text" placeholder="search for usernames"/>
   <a href="search.jsp"> Advanced Search</a>
     </form></div>
	</div>
         
        <div id="leftbar" class="sidebox">
        <table style="width:5%;">
           <tr> <td>
                   <a href="profile.jsp"/>
        <hr>
                       <%
            
                out.print("profile pic</a>");
              
                   out.println("</br>your personal info</br></br>");
                if(name!=null)
                    out.println("NAME </br>"+name);

                if(surname!=null)
                    out.println(surname+"</br></br>");
               // if(interests!=null)
                 //   out.println(interests);
                if(username!=null)
                    out.println("USERNAME</br>"+username+"</br></br>");
              // if(welcomeText!=null)
                //   out.println(welcomeText);
                if(date!=null)
                    out.println(date);
               

              %>
        
      <!--               <b><input type="image" src="imadge/Pixel_Character_6__Yoshi_by_meowmixkitty1.jpg" name="image" width="55" height="55" >
                </b>
          -->
             <a href="Pms.jsp">
                <b>Edit</b>
            </a>
         
        <hr />
        <% ArrayList temp=userInfo.getUnreadPms();
                if(!temp.isEmpty())
                {    out.println("<a href=readPms.jsp> You have "+temp.size()+"UnreadPms </a>");%>
            <a href="readPms.jsp">
                <b><input type="image" src="imadge/pms.jpg" name="pms" background-color="#C0C0C0" width="35" height="35" >
               </b>
            </a>
            <hr />
        <%}%>
        <a href="Pms.jsp">Sent A new Pm</a>
                            
		<%
                    out.print("Interests <ul>");
                                                      
                for(int i=0;i<interests.length;i++)
                    {
                out.print("<li>"+interests[i]+"</li>");
                  }
                out.print("</ul>");
                        %>
            <hr />
                </td>


                   </tr>
        </table>
        
        </div>

                        <div id"mainContainer">
                        <%
                        out.print(userInfo.getSuggestions().toString());
%>

    </div>

        
        <a href="profile.jsp?username=northy">visit northy</a>
<div id="text">
         <%
         String buddy=null;
         int y;
        userInfo.loadFriendReqs();
        ArrayList reqs=userInfo.getFriendReqs();
        if(reqs==null)
        { out.print("You have no new Friend Requests!!");}
        else
        {
        for(int i=0;i<reqs.size();i++){
              y = Integer.parseInt(reqs.get(i).toString(), 10);
           buddy = userInfo.getFriendUsername(y);
        out.print("Click on those people link to make them your friends </br> <a href=\"acceptFriend.jsp?username="+buddy+"\">"+buddy+"</a></br>");
               }
        }
        
        
    if(friends==null)
    {out.print("You dont have any friends yet!! <br/> Do you want to serch for people you may know? ");
     %>
     <form action="search.jsp">
   <input type="text" placeholder="search for usernames"/>
   <a href="search.jsp"> Advanced Search</a>
     </form>
     <%
    }
    else
    {
    out.print("click On your friends username's to unfriend them </br>");
    for(int i=0;i<friends.size();i++){               
      if(friends.get(i)!=null)
      
    out.print("<a href=\"deleteFriend.jsp?username="+friends.get(i)+"\">"+friends.get(i)+"</a></br>");  
    }    
           }
    
%>
    </body>
</html>

